<?php include('../common/pdata_mysql.php'); ?>
<?php  $pid = $_GET['pid']; 
//$pid = 44;//for test
$pdata = mysql_pconnect($hostname_pdata, $username_pdata, $password_pdata);
if (!$pdata)
  {
  die ("Can Open the database : " . mysql_error());
  }
$db_selected =  mysql_select_db("pdata",$pdata);
if (!$db_selected)
  {
  die ("Can\'t use test_db : " . mysql_error());
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php $result = mysql_query("select projectname from project where pid = ".$pid);
$row = mysql_fetch_array($result);
 ?>
<title>工程管理|<?php echo $row['projectname']; ?></title>
<style type="text/css">
.lpart {
	width: 600px;
	float: left;
}
.rpart {
	float: left;
	width: 395px;
}
</style>
<link href="/css/allstyle.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="header">
  <?php include("../common/header.php") ?>
</div>
<div id="wrap">
  <p><a href="/job/project/pro_list.php">回管理页面</a></p>
  <div class="top">
    <?php 

$sql = "SELECT * FROM project where pid = ".$pid;
$result = mysql_query($sql,$pdata) or die("Invalid query: " . mysql_error());

$row = mysql_fetch_array($result);
 ?>
    <h1> <?php echo $row['projectname']; ?> </h1>
  </div>
  <div class="lpart">
    <div id= "stage1">
      <h3>决策可研阶段</h3>
      <?php 
  $sql = "Select * from itemdetail where pid = ".$pid." and (phid = 1 or phid = 2)";
  $result = mysql_query($sql,$pdata) or die("Invalid query: " . mysql_error());
  while($row = mysql_fetch_array($result))
  {
  echo "<p>".$row['iname'] . " " . $row['procode']."</p>";
	}
  ?>
    </div>
    <div id="stage2">
      <h3>初步深度设计阶段</h3>
      <?php 
  $sql = "Select * from itemdetail where pid = ".$pid." and (phid = 3 or phid = 4)";
  $result = mysql_query($sql,$pdata) or die("Invalid query: " . mysql_error());
  while($row = mysql_fetch_array($result))
  {
  echo "<p>".$row['iname'] . " " . $row['procode']."</p>";
	}
  ?>
    </div>
    <div id="stage3">
      <h3>施工竣工阶段</h3>
      <?php 
	  $sql = "Select * from itemdetail where pid = ".$pid." and (phid = 5 or phid = 6 or phid = 7)";
	  $result = mysql_query($sql,$pdata) or die("Invalid query: " . mysql_error());
	  while($row = mysql_fetch_array($result))
	  {
	  echo "<p>".$row['iname'] . " " . $row['procode']."</p>";
		}
	  ?>
    </div>
    <?php mysql_close($pdata); ?>
  </div>
  <div class="rpart">
    <div id="newinput">
      <form action="done.php" method="post">
        <label for="pronews">工程进展报告</label>
        <textarea name="pronews" id="pronews" cols="30" rows="5"></textarea>
        <input type="hidden" id="pid" name="pid" value="<?php echo $pid;?>" />
        <input type="submit"   value="提交"/>
      </form>
    </div>
    <div id="newslist">
      <?php
	  $pdata = mysql_pconnect($hostname_pdata, $username_pdata, $password_pdata);
	  if (!$pdata)
	  {
	  die ("Can Open the database : " . mysql_error());
	  }
	  $db_selected =  mysql_select_db("pdata",$pdata);
	  if (!$db_selected)
	  {
	  die ("Can\'t use test_db : " . mysql_error());
	  } 
	  $sql = "select * from pronews where pid =  ".$pid;
	  //echo $sql;
	  $result = mysql_query($sql,$pdata);
	   $i = 1; 
	   while($row = mysql_fetch_array($result))
	  {
		
		 echo "<div>";
		 echo "<p>序号：". $i. "</p>"; 
		 echo "<p>时间：". $row['ndatetime'] ."</p>";
		 echo "<p>事件：". $row['news'] ."</p>";
		 echo "</div>"; 
		 $i ++; 
	  }
	  mysql_close($pdata);
	  ?>
    </div>
  </div>
  <div class="clean"></div>
</div>
<div id="footer">
  <?php include("../common/footer.php") ?>
</div>
</body>
</html>